﻿using B.S.Ingredients.APIRead.Application.Command.SlanBoss;
using B.S.Ingredients.Domain;
using B.S.Ingredients.ErrorCode;
using B.S.Ingredients.Infartructrue.Interfaces;
using MediatR;

namespace B.S.Ingredients.APIRead.Application.CommandHandler.SlanBossHandler
{
    public class SlanBossCreateCommandHandler : IRequestHandler<SlanBossCreateCommand, APIResult<int>>
    {
        public SlanBossCreateCommandHandler(IBaseRepository<SlanghterBoss> SlanghterBossRepository)
        {
            this.SlanghterBossRepository = SlanghterBossRepository;
        }

        public IBaseRepository<SlanghterBoss> SlanghterBossRepository { get; }

        public async Task<APIResult<int>> Handle(SlanBossCreateCommand request, CancellationToken cancellationToken)
        {
            var path = await SlanghterBossRepository.CreateAsync(request.Data);
            return new APIResult<int>
            {
                Code = ResultCode.success,
                Mag = "",
                Data = path
            };
        }
    }
}
